package com.start.dataSource.mappers;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.start.dataSource.entity.StartGenTableColumn;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StartTableColumnMapper {

    @DS("#dataSourcesKey")
    @Select("    select     column_name    columnName,  " +
            "               data_type      dataType,  " +
            "               column_comment columnComment,  " +
            "               column_key     columnKey,  " +
            "               extra,  " +
            "               is_nullable as isNullable,  " +
            "               column_type as columnType  " +
            "        from information_schema.columns  " +
            "        where table_name = #{tableName}  " +
            "          and table_schema = (select database())  " +
            "        order by ordinal_position")
    List<StartGenTableColumn> queryByTable(String dataSourcesKey,String tableName);
}
